//
//  HNSH_TZExchangeRecordHeader.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/6/14.
//

#import "HNSH_TZExchangeRecordHeader.h"

@interface HNSH_TZExchangeRecordHeader ()

/* bgView */
@property (nonatomic, strong) UIView *bgView;
/* monthLabel */
@property (nonatomic, strong) UILabel *monthLabel;
/* zhiLabel */
@property (nonatomic, strong) UILabel *zhiLabel;
/* shouLabel */
@property (nonatomic, strong) UILabel *shouLabel;
/* lineView */
@property (nonatomic, strong) UIView *lineView;

@end

@implementation HNSH_TZExchangeRecordHeader

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor appBGColor];
        [self configUI];
    }
    return self;
}

- (void)setModel:(HNSH_TZExchangeRecordHeaderModel *)model {
    _model = model;
    self.monthLabel.text = [NSString stringWithFormat:@"%@月",model.month];
    self.monthLabel.attributedText = [ST_AttributeLabelTool handleLabelWithContent:self.monthLabel.text SelectContent:@"月" CommonFont:self.monthLabel.font SpeFont:[UIFont systemFontOfSize:16] Color:self.monthLabel.textColor];
    
//    self.zhiLabel.text = [NSString stringWithFormat:@"支出：%.2f",[model.total_expend doubleValue]];
//    self.shouLabel.text = [NSString stringWithFormat:@"收入：%.2f",[model.total_income doubleValue]];
}

- (void)setMonthString:(NSString *)monthString {
    _monthString = monthString;
    self.monthLabel.text = [NSString stringWithFormat:@"%@月",monthString];
    self.monthLabel.attributedText = [ST_AttributeLabelTool handleLabelWithContent:self.monthLabel.text SelectContent:@"月" CommonFont:self.monthLabel.font SpeFont:[UIFont systemFontOfSize:16] Color:self.monthLabel.textColor];
}

- (void)configUI {
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.monthLabel];
//    [self.bgView addSubview:self.zhiLabel];
//    [self.bgView addSubview:self.shouLabel];
    [self.bgView addSubview:self.lineView];
    
    self.monthLabel.attributedText = [ST_AttributeLabelTool handleLabelWithContent:self.monthLabel.text SelectContent:@"月" CommonFont:self.monthLabel.font SpeFont:[UIFont systemFontOfSize:16] Color:self.monthLabel.textColor];
    
    [self.monthLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.top.mas_equalTo(12);
        make.height.mas_equalTo(40);
    }];
    
//    [self.zhiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.mas_equalTo(16);
//        make.top.mas_equalTo(54);
//        make.height.mas_equalTo(17);
//    }];
//    
//    [self.shouLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.zhiLabel.mas_right).offset(20);
//        make.top.mas_equalTo(54);
//        make.height.mas_equalTo(17);
//    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
}

#pragma mark lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(10, 10, kScreenWidth-20, 84)];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
        [self clipCornerWithView:_bgView cornerWidth:4 cornerType:UIRectCornerTopLeft|UIRectCornerTopRight];
    }
    return _bgView;
}

- (UILabel *)monthLabel {
    if (!_monthLabel) {
        _monthLabel = [[UILabel alloc]init];
        _monthLabel.text = @"1月";
        _monthLabel.textColor = [UIColor appBlackLabelColor];
        _monthLabel.font = [UIFont boldSystemFontOfSize:28];
    }
    return _monthLabel;
}

- (UILabel *)zhiLabel {
    if (!_zhiLabel) {
        _zhiLabel = [[UILabel alloc]init];
        _zhiLabel.text = @"支出：0.00";
        _zhiLabel.textColor = [UIColor colorWithHexString:@"#666666"];
        _zhiLabel.font = [UIFont systemFontOfSize:12];
    }
    return _zhiLabel;
}

- (UILabel *)shouLabel {
    if (!_shouLabel) {
        _shouLabel = [[UILabel alloc]init];
        _shouLabel.text = @"收入：0.00";
        _shouLabel.textColor = [UIColor colorWithHexString:@"#666666"];
        _shouLabel.font = [UIFont systemFontOfSize:12];
    }
    return _shouLabel;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor colorWithHexString:@"#F3F3F3"];
    }
    return _lineView;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
